rm(list= ls())

library(tidyverse)

ba <- readRDS('data/BA_employment_muni.rds') %>%
  filter(state %in% c('Bayern', 'Nordrhein-Westfalen')) 

means <- ba %>% 
  group_by(date, treated) %>%
  summarise(mean_emp = mean(emp_ref_pc, na.rm = T)) %>%
  mutate(treated_label = ifelse(treated == 1, 'Priority review abolished', 'Priority review retained'))


p1 <- ggplot(means, 
             aes(x = date, y = mean_emp, 
                 group = treated_label, 
                 col = factor(treated_label), 
                 shape = factor(treated_label), 
                 linetype = factor(treated_label))) + 
  geom_vline(xintercept = as.Date('2016-08-06'), linetype = 'dotted') + 
  scale_color_grey() +
  geom_line() + 
  geom_point(fill = 'white', size = 1.5) + 
  theme_bw() + 
  scale_shape_manual(values = c(21, 22),
                     name = '') +
  xlab('') + 
  theme(legend.position = 'bottom') + 
  ylab('Refugee employment\n (per 1,000 capita)') +
  scale_x_date(date_breaks = "1 year", date_labels =  "%Y") +
  labs(col = '',
       shape = '',
       linetype = '') + 
  scale_linetype_manual(values = c('solid', 'dotdash'))

p1




